(function(){"use strict";BX.namespace("BX.Landing");var e=BX.Landing.Utils.style;var n=BX.Landing.Utils.addClass;var t=BX.Landing.Utils.removeClass;var r=BX.Landing.Utils.onTransitionEnd;BX.Landing.BlockHeaderEntry=function(e){this.headerNode=e;this.wrapperNode=e.parentNode;this.fixMomentNodes=this.wrapperNode.querySelectorAll(BX.Landing.BlockHeaderEntry.FIX_MOMENT_SELECTOR);this.hiddenSectionsNodes=this.headerNode.querySelectorAll(BX.Landing.BlockHeaderEntry.SECTION_HIDDEN_SELECTOR);this.mode=this.getMode();this.prevState=0;var n=document.querySelector(".landing-pub-top-panel-wrapper");this.headerOffset=n?n.offsetHeight:0};BX.Landing.BlockHeaderEntry.HEADER_SELECTOR=".u-header";BX.Landing.BlockHeaderEntry.SECTION_HIDDEN_SELECTOR=".u-header__section--hidden";BX.Landing.BlockHeaderEntry.FIX_MOMENT_SELECTOR="[data-header-fix-moment-classes], [data-header-fix-moment-exclude]";BX.Landing.BlockHeaderEntry.STATE_IN_FLOW=10;BX.Landing.BlockHeaderEntry.STATE_ON_TOP=20;BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT=30;BX.Landing.BlockHeaderEntry.DIRECTION_TOP_TO_BOTTOM=1;BX.Landing.BlockHeaderEntry.DIRECTION_BOTTOM_TO_TOP=-1;BX.Landing.BlockHeaderEntry.THRESHOLD_FULL=1;BX.Landing.BlockHeaderEntry.STICKY_CLASS="u-header--sticky";BX.Landing.BlockHeaderEntry.FLOAT_CLASS="u-header--float";BX.Landing.BlockHeaderEntry.MODE_STICKY=10;BX.Landing.BlockHeaderEntry.MODE_STICKY_RELATIVE=20;BX.Landing.BlockHeaderEntry.MODE_STATIC=30;BX.Landing.BlockHeaderEntry.IN_FLOW_CLASSES=["js-header-in-flow"];BX.Landing.BlockHeaderEntry.ON_TOP_CLASSES=["js-header-on-top"];BX.Landing.BlockHeaderEntry.FIX_MOMENT_CLASSES=["js-header-fix-moment"];BX.Landing.BlockHeaderEntry.FIX_MOMENT_ADD_DATA="header-fix-moment-classes";BX.Landing.BlockHeaderEntry.FIX_MOMENT_REMOVE_DATA="header-fix-moment-exclude";BX.Landing.BlockHeaderEntry.getHeaderNodeByWrapper=function(e){return e.querySelector(BX.Landing.BlockHeaderEntry.HEADER_SELECTOR)};BX.Landing.BlockHeaderEntry.prototype={getNodeForObserve:function(){return this.wrapperNode},getMode:function(){if(BX.hasClass(this.headerNode,BX.Landing.BlockHeaderEntry.STICKY_CLASS)){if(BX.hasClass(this.headerNode,BX.Landing.BlockHeaderEntry.FLOAT_CLASS)){return BX.Landing.BlockHeaderEntry.MODE_STICKY}return BX.Landing.BlockHeaderEntry.MODE_STICKY_RELATIVE}return BX.Landing.BlockHeaderEntry.MODE_STATIC},getCurrentState:function(e){if(e.isIntersecting){if(!this.isOnTop(e)){return BX.Landing.BlockHeaderEntry.STATE_IN_FLOW}else if(e.intersectionRatio===BX.Landing.BlockHeaderEntry.THRESHOLD_FULL){return BX.Landing.BlockHeaderEntry.STATE_IN_FLOW}else if(e.intersectionRatio<BX.Landing.BlockHeaderEntry.THRESHOLD_FULL){return BX.Landing.BlockHeaderEntry.STATE_ON_TOP}}else{if(!this.isOnTop(e)){return BX.Landing.BlockHeaderEntry.STATE_IN_FLOW}else{return BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT}}},isOnTop:function(e){return e.boundingClientRect.top<=0},getDirection:function(e){if(this.prevState===null){return 0}if(e>this.prevState){return BX.Landing.BlockHeaderEntry.DIRECTION_TOP_TO_BOTTOM}return BX.Landing.BlockHeaderEntry.DIRECTION_BOTTOM_TO_TOP},isOverScreen:function(e){return e.boundingClientRect.height>=e.rootBounds.height},setInFlow:function(){if(this.mode===BX.Landing.BlockHeaderEntry.MODE_STICKY_RELATIVE){void e(this.wrapperNode,{height:"auto"});void e(this.headerNode,{top:"0"})}n(this.headerNode,BX.Landing.BlockHeaderEntry.IN_FLOW_CLASSES);t(this.headerNode,BX.Landing.BlockHeaderEntry.ON_TOP_CLASSES);BX.onCustomEvent("BX.Landing.BlockAssets.Header:onSetInFlow",[{node:this.headerNode,data:{height:this.headerNode.offsetHeight}}])},setOnTop:function(){if(this.mode===BX.Landing.BlockHeaderEntry.MODE_STICKY_RELATIVE){void e(this.wrapperNode,{height:this.wrapperNode.offsetHeight+"px"})}var i=this.headerNode.offsetHeight+"px";void e(this.headerNode,{height:"0px",opacity:"0",overflow:"hidden"});r(this.headerNode).then(function(){n(this.headerNode,BX.Landing.BlockHeaderEntry.ON_TOP_CLASSES);t(this.headerNode,BX.Landing.BlockHeaderEntry.IN_FLOW_CLASSES);return this.hideSections()}.bind(this)).then(function(){void e(this.headerNode,{height:i,opacity:"1",top:this.headerOffset+"px"});return r(this.headerNode)}.bind(this)).then(function(){void e(this.headerNode,{height:null,opacity:null,overflow:null});return Promise.all([this.setFixMoment(),r(this.headerNode)])}.bind(this)).then(function(){BX.onCustomEvent("BX.Landing.BlockAssets.Header:onSetOnTop",[{node:this.headerNode,data:{height:this.headerNode.offsetHeight}}])}.bind(this))},setFixMoment:function(){if(this.prevState<BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT){return Promise.resolve()}var e=[];n(this.headerNode,BX.Landing.BlockHeaderEntry.FIX_MOMENT_CLASSES);e.push(r(this.headerNode));this.fixMomentNodes.forEach(function(i){var d=BX.data(i,BX.Landing.BlockHeaderEntry.FIX_MOMENT_ADD_DATA);if(d!==undefined){n(i,d.split(" "))}var o=BX.data(i,BX.Landing.BlockHeaderEntry.FIX_MOMENT_REMOVE_DATA);if(o!==undefined){t(i,o.split(" "))}e.push(r(i))});return Promise.all(e)},unsetOnTop:function(){this.unsetFixMoment().then(function(){BX.onCustomEvent("BX.Landing.BlockAssets.Header:onUnsetOnTop",[{node:this.headerNode,data:{height:this.headerNode.offsetHeight}}])}.bind(this))},unsetFixMoment:function(){var e=[];t(this.headerNode,BX.Landing.BlockHeaderEntry.FIX_MOMENT_CLASSES);e.push(r(this.headerNode));e.push(this.showSections());this.fixMomentNodes.forEach(function(i){var d=BX.data(i,BX.Landing.BlockHeaderEntry.FIX_MOMENT_ADD_DATA);if(d!==undefined){t(i,d.split(" "))}var o=BX.data(i,BX.Landing.BlockHeaderEntry.FIX_MOMENT_REMOVE_DATA);if(o!==undefined){n(i,o.split(" "))}e.push(r(i))});return Promise.all(e)},hideSections:function(){var e=[];this.hiddenSectionsNodes.forEach(function(n){n.style.setProperty("height",0);n.style.setProperty("border","none","important");n.style.setProperty("overflow","hidden");n.style.setProperty("padding",0,"important");e.push(r(n))});return Promise.all(e)},showSections:function(){var e=[];this.hiddenSectionsNodes.forEach(function(n){n.style.removeProperty("height");n.style.removeProperty("border");n.style.removeProperty("overflow");n.style.removeProperty("padding");e.push(r(n))});return Promise.all(e)}};BX.Landing.BlockHeaderEntry.onIntersection=function(e){e.forEach(function(e){var n=BX.Landing.BlockHeaders.getInstance();var t=n.getEntryByIntersectionTarget(e.target);if(t.mode===BX.Landing.BlockHeaderEntry.MODE_STATIC){return}var r=t.getCurrentState(e);if(r!==t.prevState){if(r===BX.Landing.BlockHeaderEntry.STATE_IN_FLOW){t.setInFlow()}else if(r===BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT){if(t.prevState<BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT){t.setOnTop()}}var i=t.getDirection(r);if(i<0&&r<BX.Landing.BlockHeaderEntry.STATE_FIX_MOMENT){t.unsetOnTop()}t.prevState=r}else if(t.isOverScreen(e)){t.wrapperNode.scrollIntoView({behavior:"smooth"});t.setOnTop();t.prevState=BX.Landing.BlockHeaderEntry.STATE_ON_TOP}})}})();
//# sourceMappingURL=block-header-entry.map.js